package cn.iocoder.yudao.module.member.agency.controller.admin;

import cn.iocoder.yudao.framework.business.basic.controller.CrudController;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.member.agency.service.AgencyPackageService;
import cn.iocoder.yudao.module.member.agency.vo.AgencyPackageQueryDTO;
import cn.iocoder.yudao.module.member.agency.vo.AgencyPackageSaveDTO;
import cn.iocoder.yudao.module.member.agency.vo.AgencyPackageVO;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

@Tag(name = "管理后台 - 招商人员身份套餐")
@RestController
@RequestMapping("/member/agency-package")
@Validated
public class AgencyPackageController implements CrudController<AgencyPackageVO, AgencyPackageSaveDTO, AgencyPackageQueryDTO> {
    @Resource
    private AgencyPackageService agencyPackageService;

    @PreAuthorize("@ss.hasAnyRoles('super_admin', 'platform_admin', 'tenant_admin')")
    @Override
    public CommonResult<Long> create(AgencyPackageSaveDTO param) {
        return success(agencyPackageService.create(param));
    }

    @PreAuthorize("@ss.hasAnyRoles('super_admin', 'platform_admin', 'tenant_admin')")
    @Override
    public CommonResult<Boolean> update(AgencyPackageSaveDTO param) {
        return success(agencyPackageService.update(param));
    }

    @PreAuthorize("@ss.hasAnyRoles('super_admin', 'platform_admin', 'tenant_admin')")
    @Override
    public CommonResult<Boolean> delete(Long id) {
        return success(agencyPackageService.delete(id));
    }

    @PreAuthorize("@ss.hasPermission('member:agency:package')")
    @Override
    public CommonResult<AgencyPackageVO> getDetail(Long id) {
        return success(agencyPackageService.getDetail(id));
    }

    @PreAuthorize("@ss.hasPermission('member:agency:package')")
    @Override
    public CommonResult<PageResult<AgencyPackageVO>> getPage(Integer pageNo, Integer pageSize, AgencyPackageQueryDTO param) {
        return success(agencyPackageService.getPage(pageNo, pageSize, param));
    }

}